package com.xx.jicheng.controller.admin;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.yihang.common.spring.JsonModel;

import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import com.xx.jicheng.entity.Product;
import com.xx.jicheng.service.ProductService;

@Controller
public class AdminProductController {

	@Autowired
	private ProductService productService;

	@RequestMapping("/admin/product/product")
	public void product() {

	}

	@RequestMapping("/admin/product/product/find")
	@ResponseBody
	public Map<String, Object> find(int page, int rows, String cid, JsonModel model) {
		
		PageList<Product> list = (PageList<Product>) productService.findByCid(cid,new PageBounds(page, rows));
		model.add("total", list.getPaginator().getTotalCount());
		model.add("rows", list);
		return model.asMap();
	}

}
